/* This file contains the entry point for the program
*
*
*/

#include "sudoku.h"

int main(int argc, char * argv[])
{
	int iter = 0;
	int x, y;
	int sx, sy;
	long long t1, t2, t3, diff;
	double t; 
	char input[12][GRID_SIZE * GRID_SIZE + 1] =
	{"4.....8.5.3..........7......2.....6.....8.4......1.......6.3.7.5..2.....1.4......",
		"6.4..83.9...3.2.78.829..4.5.6..9..34...2.3...73..1..8.5.3..486.42.6.1...8.65..2..",
		"8.1...3.6.2.641.7.6.......2.3.8.4.9..1.....8..5.2.9.4.3.......1.9.387.6.4.7...9.8",
		"52...6.........7.13...........4..8..6......5...........418.........3..2...87.....",
		"6.....8.3.4.7.................5.4.7.3..2.....1.6.......2.....5.....8.6......1....",
		"48.3............71.2.......7.5....6....2..8.............1.76...3.....4......5....",
		"....14....3....2...7..........9...3.6.1.............8.2.....1.4....5.6.....7.8...",
		"......52..8.4......3...9...5.1...6..2..7........3.....6...1..........7.4.......3.",
		"6.2.5.........3.4..........43...8....1....2........7..5..27...........81...6.....",
		".524.........7.1..............8.2...3.....6...9.5.....1.6.3...........897........",
		".................................................................................",
		"5.6.7.......1.5.93.....2.6.3..41....8.15.39.7....96..8.9.2.....78.6.4.......5.4.6"};

	Grid grid = newGrid();
	Grid dout = newGrid();
	Grid sol = newGrid();
	populateGrid(input[atoi(argv[1])], grid);
	printf("puzzle\n");
	prtGrid(grid, 1);
	
	//printf("Bitcounts\n");
	//prtGridBitcount(grid);	
	//prtGrid(grid, 1);	
	//printf("Bitcounts after markup\n");
	//prtGridBitcount(grid);
	
	// Must markup grid before calling backtrack
	t1 = rdtsc();
	markup(grid);
	
	// printf("Try deterministic tests.\n");
	determine(grid, dout);
	t2 = rdtsc();
	printf("Only deterministic tests needed.\n");
	t = t2 - t1;
	printf("Deterministic time: %f\n",t);
	prtGrid(dout, 1);


	delGrid(grid);
	delGrid(dout);	
	delGrid(sol);
	return 0;  
}
